package com.hlt.shuiliting.dao;

import java.util.List;
import java.util.Map;

import com.hlt.shuiliting.database.DBUtil;
import com.hlt.shuiliting.valuebean.ZhengDiCQ;

public class ZhengDiCQDAO {

	private int updateCount;
	private int pageCount;
	
	public List list(int GongChengXMID) {
		String sql = "select * from ZhengDiCQ where GongChengXMID = ?";
		Object[] params = {GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		
		return list;
	}
	
	public List list(int GongChengXMID, int pageSize , int pageNum) {
		String sql = "select * from ZhengDiCQ where GongChengXMID = ?";
		Object[] params = {GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet(pageSize, pageNum);
		pageCount = myDB.getPageCount();
		myDB.closed();
		
		return list;
	}
	
	public Map view(int id) {
		List list = null;
		String sql = "select * from ZhengDiCQ where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		list = myDB.getResultSet();
		Map map = (Map)list.get(0);
		
		return map;
	}
	public int insert(ZhengDiCQ zhengDiCQ) {
		String sql = "insert into ZhengDiCQ values (seq_ZhengDiCQ.nextVal, ?, to_date(?,'yyyy-mm-dd'), ?,?, ?, ?, ?,?, ?, ?, to_date(?,'yyyy-mm-dd'), ?, ?, ?, ?,?)";
		String ZhuangTai = zhengDiCQ.getZhuangTai();
		String JiLuSJ = zhengDiCQ.getJiLuSJ();
		String LuRuR = zhengDiCQ.getLuRuR();
		String XiangMuYDSPBM = zhengDiCQ.getXiangMuYDSPBM();
		String XiangMuYDSPYJ = zhengDiCQ.getXiangMuYDSPYJ();
		String XiangMuYDXKZMH = zhengDiCQ.getXiangMuYDXKZMH();
		String ChaiQianFZDW = zhengDiCQ.getChaiQianFZDW();
		String ChaiQianFZR = zhengDiCQ.getChaiQianFZR();
		String XiangMuZDCQGGBM = zhengDiCQ.getXiangMuZDCQGGBM();
		String ChaiQianFW = zhengDiCQ.getChaiQianFW();
		String ChaiQianSJ = zhengDiCQ.getChaiQianSJ();
		String ChaiQianFS = zhengDiCQ.getChaiQianFS();
		String ShangQiYZFJE = zhengDiCQ.getShangQiYZFJE();
		String BenQiZFJE = zhengDiCQ.getBenQiZFJE();
		String LeiJiZFJE = zhengDiCQ.getLeiJiZFJE();
		String GongChengXMID = zhengDiCQ.getGongChengXMID();
		Object[] params = {
				ZhuangTai, 
				JiLuSJ,
				LuRuR,
				XiangMuYDSPBM,
				XiangMuYDSPYJ,
				XiangMuYDXKZMH,
				ChaiQianFZDW,
				ChaiQianFZR,
				XiangMuZDCQGGBM,
				ChaiQianFW,
				ChaiQianSJ,
				ChaiQianFS,
				ShangQiYZFJE,
				BenQiZFJE,
				LeiJiZFJE,
				GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int update(ZhengDiCQ zhengDiCQ) {
		String sql = "update ZhengDiCQ set ZhuangTai = ?, JiLuSJ = to_date(?,'yyyy-mm-dd'), LuRuR = ?, XiangMuYDSPBM = ?, XiangMuYDSPYJ = ?," +
				" XiangMuYDXKZMH = ?, ChaiQianFZDW = ?, ChaiQianFZR = ?, XiangMuZDCQGGBM = ?, " +
				"ChaiQianFW = ?, ChaiQianSJ = to_date(?,'yyyy-mm-dd'), ChaiQianFS = ?, " +
				"ShangQiYZFJE = ?, BenQiZFJE = ?, LeiJiZFJE = ?, GongChengXMID = ? where ID = ?";
		String ID = zhengDiCQ.getID();
		String ZhuangTai = zhengDiCQ.getZhuangTai();
		String JiLuSJ = zhengDiCQ.getJiLuSJ();
		String LuRuR = zhengDiCQ.getLuRuR();
		String XiangMuYDSPBM = zhengDiCQ.getXiangMuYDSPBM();
		String XiangMuYDSPYJ = zhengDiCQ.getXiangMuYDSPYJ();
		String XiangMuYDXKZMH = zhengDiCQ.getXiangMuYDXKZMH();
		String ChaiQianFZDW = zhengDiCQ.getChaiQianFZDW();
		String ChaiQianFZR = zhengDiCQ.getChaiQianFZR();
		String XiangMuZDCQGGBM = zhengDiCQ.getXiangMuZDCQGGBM();
		String ChaiQianFW = zhengDiCQ.getChaiQianFW();
		String ChaiQianSJ = zhengDiCQ.getChaiQianSJ();
		String ChaiQianFS =zhengDiCQ.getChaiQianFS();
		String ShangQiYZFJE = zhengDiCQ.getShangQiYZFJE();
		String BenQiZFJE =zhengDiCQ.getBenQiZFJE();
		String LeiJiZFJE = zhengDiCQ.getLeiJiZFJE();
		String GongChengXMID = zhengDiCQ.getGongChengXMID();
		Object[] params = {
				ZhuangTai, 
				JiLuSJ,
				LuRuR,
				XiangMuYDSPBM,
				XiangMuYDSPYJ,
				XiangMuYDXKZMH,
				ChaiQianFZDW,
				ChaiQianFZR,
				XiangMuZDCQGGBM,
				ChaiQianFW,
				ChaiQianSJ,
				ChaiQianFS,
				ShangQiYZFJE,
				BenQiZFJE,
				LeiJiZFJE,
				GongChengXMID,
				ID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int delete(int id) {
		String sql = "delete from ZhengDiCQ where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int getPageCount() {
		return pageCount;
	}
}
